#ifndef CMESSAGESYSTEM_H_
#define CMESSAGESYSTEM_H_

#include <queue>
#include <string>
using std::queue;
using std::string;

typedef void (*MessageHandler)(string, void *, void *);

struct tMessage
{
	string	m_szMessageID;
	void   *m_pSender;
	void   *m_pArgs;

	tMessage() { m_pSender = m_pArgs = 0; }

	void SetParams(string szID, void *pSender, void *pArgs)
	{
		m_szMessageID = szID;
		m_pSender = pSender;
		m_pArgs = pArgs;
	}
};

class CMessenger
{
private:
	MessageHandler	m_pfHandler;
	queue<tMessage>	m_qMessages;

	CMessenger() { }
	CMessenger(CMessenger &) { }
	CMessenger &operator=(CMessenger &) { }
public:
	~CMessenger() { }

	static CMessenger *GetInstance();

	void SetHandler(MessageHandler pfHandler) { m_pfHandler = pfHandler; }

	void SendMsg(string szID, void *pSender, void *pArgs);
	void PostMsg(string szID, void *pSender, void *pArgs);

	void ProcessMessages();
	void ClearMessages();
};

#endif